package com.qifan.energy.activity;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentPagerAdapter;
import androidx.viewpager.widget.ViewPager;

import android.os.Bundle;

import com.qifan.energy.base.BaseActivity;
import com.qifan.energy.fragment.OrderAllFragment;
import com.qifan.energy.fragment.OrderReadyPayFragment;
import com.qifan.energy.fragment.OrderReadyReceiveFragment;
import com.qifan.energy.fragment.OrderReadyShipFragment;
import com.qifan.energy.R;
import com.google.android.material.tabs.TabLayout;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

public class MyOrderActivity extends BaseActivity {

    @BindView(R.id.tablayout)
    TabLayout tabLayout;
    @BindView(R.id.viewpager)
    ViewPager viewPager;
    private List<Fragment> pageList = new ArrayList<Fragment>() {{
        add(OrderAllFragment.newInstance());
        add(OrderReadyPayFragment.newInstance());
        add(OrderReadyShipFragment.newInstance());
        add(OrderReadyReceiveFragment.newInstance());
    }};
    private List<String> titles = new ArrayList() {{
        add("全部");
        add("待付款");
        add("待发货");
        add("待收货");
    }};

    /*@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my_order);
    }*/

    @Override
    protected int getLayoutId() {
        return R.layout.activity_my_order;
    }

    @Override
    protected void initView(Bundle savedInstanceState) {

        /* 更改状态栏 */
        changeStatusTransparentFontBlack();

        viewPager.setAdapter(new FragmentPagerAdapter(getSupportFragmentManager(),0) {
            @NonNull
            @Override
            public Fragment getItem(int position) {
                return pageList.get(position);
            }

            @Override
            public int getCount() {
                return pageList.size();
            }

            @Nullable
            @Override
            public CharSequence getPageTitle(int position) {
                return titles.get(position);
            }
        });
        //预加载页面个数
        viewPager.setOffscreenPageLimit(2);
        //关联ViewPager
        tabLayout.setupWithViewPager(viewPager);
    }

    @Override
    protected void initData() {

    }
}
